﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace neside3.func_edit
{
    /// <summary>
    /// TabHead.xaml 的交互逻辑
    /// </summary>
    public partial class TabHead : UserControl
    {
        public TabHead()
        {
            InitializeComponent();
        }
        public event Action onBtnExitDown;
        public TabHead(string filename)
        {
            InitializeComponent();
            this.title.Text = System.IO.Path.GetFileName(filename);
            SetNormal();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            onBtnExitDown?.Invoke();
        }
        public void SetEditState(bool enable)
        {
            if (enable)
            {
                if (this.title.Text[0] != '*')
                {
                    this.title.Text = "*" + this.title.Text;
                }
            }
            else
            {
                if(this.title.Text[0]=='*')
                {
                    this.title.Text = this.title.Text.Substring(1);
                }
            }
        }
        public void SetNormal()
        {
            this.title.Background = new SolidColorBrush(Color.FromRgb(0xed, 0xed, 0xed));
        }
        public void SetWarn()
        {
            this.title.Background = new SolidColorBrush(Color.FromRgb(0xad, 0xad, 0x3c));
        }
        public void SetError()
        {
            this.title.Background = new SolidColorBrush(Color.FromRgb(0xad, 0x3c, 0x3c));
        }
    }
}
